package com.jswdwsx.ddns.config;

import com.aliyun.alidns20150109.Client;
import com.aliyun.teaopenapi.models.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AliConfig {

    final
    AliProperties aliProperties;

    public AliConfig(AliProperties aliProperties) {
        this.aliProperties = aliProperties;
    }

    @Bean
    public Client aliDnsClient() throws Exception {
        Config config = new Config()
                // 您的AccessKey ID
                .setAccessKeyId(aliProperties.getAccessKeyId())
                // 您的AccessKey Secret
                .setAccessKeySecret(aliProperties.getAccessKeySecret());
        // 访问的域名
        config.endpoint = "alidns.cn-hangzhou.aliyuncs.com";
        return new Client(config);
    }
}
